package com.whpost.service.dao.t;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whpost.service.entity.t.TMenu;
import com.whpost.service.entity.t.TXzjg;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TXzjgDao extends BaseMapper<TXzjg> {

    @Select("select * from t_xzjg where ${ew.sqlSegment}")
    @Results(id="tXzjgMap",value = {
            @Result(column="pid",property="pXzjg",
                    one=@One(
                            select="com.whpost.service.dao.t.TXzjgDao.selectById")
            ),
            @Result(column="pid",property="pid")
    })
    List<TXzjg> getTXzjgList(@Param("ew") QueryWrapper wrapper);

    //自己和下级
    @Select("SELECT * FROM t_xzjg START WITH id = #{id} CONNECT BY PRIOR id = pid")
    @ResultMap(value="tXzjgMap")
    List<TXzjg> getXzjgXj(Long id);

    //查询下级，不包含自己
    @Select("SELECT * from t_xzjg where id!=#{id} CONNECT BY PRIOR id = pid START WITH id = #{id}")
    @ResultMap(value="tXzjgMap")
    List<TXzjg> getXzjgXjNoRoot(Long id);

    @Select("SELECT * from t_xzjg where id=#{id}")
    @ResultMap(value="tXzjgMap")
    TXzjg getXzjgById(String id);

}